package com.gec.zhs.utils;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author zhs
 * @version 1.0
 * @date 2025-01-06
 * @description
 */
@Configuration
@EnableKnife4j
@EnableOpenApi
public class Knife4jConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .apiInfo(apiInfo())
                .select()
                //.apis(RequestHandlerSelectors.basePackage("com.gec.zhs"))
                .apis(RequestHandlerSelectors.basePackage("com.gec.zhs"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .description("视频在线api接口文档")
                .contact(new Contact("zhs", "https://zhs.com", "zhs@qq.com"))
                .version("v1.0.0")
                .title("视频在线api接口文档")
                .build();
    }
}
